package com.richapp.launcher.database.system.dao;

import android.content.Context;
import android.util.Log;

import com.j256.ormlite.stmt.QueryBuilder;
import com.richapp.launcher.database.system.SystemBaseDao;
import com.richapp.launcher.database.system.mode.UserLogin;

/**
 * Created by jack on 15/11/19.
 */
public class UserLoginDao extends SystemBaseDao<UserLogin> {

    public UserLoginDao(Context context) {
        super(context, UserLogin.class);
    }

    public UserLogin getUserLoginByClientId(String clientId){
        UserLogin userLogin = null;
        try {
            QueryBuilder<UserLogin,Integer> queryBuilder = gettOp().queryBuilder();
            queryBuilder.where().eq("clientId",clientId);
            userLogin = queryBuilder.queryForFirst();
        }catch (Exception e){
            Log.e(getClass().getName(), e.getMessage());
        }
        return userLogin;
    }

    public UserLogin getUserLoginByPhoneUid(String phoneUid){
        UserLogin userLogin = null;
        try {
            QueryBuilder<UserLogin,Integer> queryBuilder = gettOp().queryBuilder();
            queryBuilder.where().eq("phoneUid",phoneUid);
            userLogin = queryBuilder.queryForFirst();
        }catch (Exception e){
            Log.e(getClass().getName(), e.getMessage());
        }
        return userLogin;
    }
}
